<template>
  <div id="center">
    <div class="up">
      <div
        class="bg-color-black item"
        v-for="item in titleItem"
        :key="item.title"
      >
        <div style="color: #5cbafd">
          {{ item.title }}
        </div>
        <div class="number-style">
          {{ item.number }}
        </div>
        <!-- <p class="ml-3 colorBlue fw-b title-style">{{ item.title }}</p>
        <div>
          <dv-digital-flop
            class="dv-dig-flop ml-1 mt-2 pl-3"
            :config="item.number"
          />
        </div> -->
      </div>
    </div>
    <div class="down">
      <div class="ranking bg-color-black">
        <span>
          <icon name="chart-pie" class="text-icon"></icon>
        </span>
        <span class="title-style text mx-2 mb-1 pl-3">知识分享排行榜</span>
        <dv-scroll-ranking-board
          ref="scrollRanking"
          class="dv-scr-rank-board mt-1"
          :config="ranking"
        />
      </div>
      <div class="percent">
        <div class="item bg-color-black">
          <span>今日档案通过率</span>
          <CenterChart
            style="display: flex; justify-content: center"
            :id="rate[0].id"
            :tips="rate[0].tips"
            :colorObj="rate[0].colorData"
          />
        </div>
        <div class="item bg-color-black">
          <span>今日知识通过率</span>
          <CenterChart
            style="display: flex; justify-content: center"
            :id="rate[1].id"
            :tips="rate[1].tips"
            :colorObj="rate[1].colorData"
          />
        </div>
        <!-- <div class="water">
          <dv-water-level-pond class="dv-wa-le-po" :config="water" />
        </div> -->
      </div>
    </div>
  </div>
</template>

<script>
import CenterChart from "@/components/echart/center/centerChartRate";
import { getTodaySubmit, getPassRate } from '../api/archive'
import { getRanks, getKnowMainPass, getMiddleConclusion } from '../api/know'

export default {
  data () {
    return {
      titleItem: [
        {
          title: "今年累计档案提交数",
          number: 0,
        },
        {
          title: "今年累计档案通过数",
          number: 0,
        },
        {
          title: "今日累计档案通过数",
          number: 0,
        },
        {
          title: "今年累计知识提交数",
          number: 0,
        },
        {
          title: "今年累计知识通过数",
          number: 0,
        },
        {
          title: "今日累计知识通过数",
          number: 0,
        },
      ],
      ranking: {
        data: [],
        carousel: "single",
        unit: "次",
      },
      water: {
        data: [24, 45],
        shape: "roundRect",
        formatter: "{value}%",
        waveNum: 3,
      },
      // 通过率和达标率的组件复用数据
      rate: [
        {
          id: "centerRate1",
          tips: 0,
          colorData: {
            textStyle: "#3fc0fb",
            series: {
              color: ["#00bcd44a", "transparent"],
              dataColor: {
                normal: "#03a9f4",
                shadowColor: "#97e2f5",
              },
            },
          },
        },
        {
          id: "centerRate2",
          tips: 0,
          colorData: {
            textStyle: "#67e0e3",
            series: {
              color: ["#faf3a378", "transparent"],
              dataColor: {
                normal: "#ff9800",
                shadowColor: "#fcebad",
              },
            },
          },
        },
      ],
    };
  },
  components: {
    CenterChart,
  },
  mounted () {
    this.getTodaySubmit();
    this.getPassRate();
    this.getRanks()
    this.getKnowMainPass()
    this.getMiddleConclusion()
  },
  methods: {
    // 获取知识分享排行榜
    getRanks () {
      getRanks().then((res) => {
        this.ranking.data = res.data
        this.ranking = { ...this.ranking }
      })
    },
    // 今日知识通过率
    getKnowMainPass () {
      getKnowMainPass().then((res) => {
        this.rate[1].tips = parseInt(res);
      })
    },
    // 获取今日档案提交量
    getTodaySubmit () {
      getTodaySubmit().then((res) => {
        this.titleItem[0].number = res.data.allSubmitCountYear;
        this.titleItem[1].number = res.data.allPassCountYear;
        this.titleItem[2].number = res.data.allPassCountToday;
      })
    },
    // 获取今年累计知识提交等数据
    getMiddleConclusion () {
      getMiddleConclusion().then((res) => {
        this.titleItem[3].number = res.year_commit;
        this.titleItem[4].number = res.year_pass;
        this.titleItem[5].number = res.day_pass;
      })
    },
    getPassRate () {
      getPassRate().then((res) => {
        this.rate[0].tips = parseInt(res.data.passRateToday);
      });
      // this.API.post(this.API.url.getPassRate).then((res) => {
      //   this.rate[0].tips = parseInt(res.data.passRateToday);
      // });
    },
  },
};
</script>

<style lang="scss" scoped>
#center {
  display: flex;
  flex-direction: column;
  .up {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
    .item {
      border-radius: 6px;
      padding-top: 8px;
      margin-top: 8px;
      width: 32%;
      height: 70px;
      .dv-dig-flop {
        width: 150px;
        height: 30px;
      }
    }
  }
  .down {
    padding: 6px 4px;
    padding-bottom: 0;
    width: 100%;
    display: flex;
    height: 255px;
    justify-content: space-between;
    .bg-color-black {
      border-radius: 5px;
    }
    .ranking {
      padding: 10px;
      width: 59%;
      .dv-scr-rank-board {
        height: 225px;
      }
    }
    .percent {
      width: 40%;
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      .item {
        width: 50%;
        // height: 120px;
        span {
          margin-top: 8px;
          font-size: 14px;
          display: flex;
          justify-content: center;
        }
      }
      .water {
        width: 100%;
        .dv-wa-le-po {
          height: 120px;
        }
      }
    }
  }
}

.number-style {
  font-size: 30px;
  color: #5dd1c5;
  margin: 8px 10px;
  // color: #6eadff;
}
</style>
